<?php

/**
 * @author FROSTY (valik619)
 * @site nadmad.ru
 * @mail valik619@inbox.ru
 */

$categories=mysql_query("SELECT * FROM `cat` ORDER BY `order`");


while($row=mysql_fetch_assoc($categories)){
    echo '<div class="title"><a href="http://'.$set['home'].'/cat/index.php?id='.$row['id'].'">'.$row['name'].'</a></div>';
    
    $posts=mysql_query("SELECT * FROM `posts` WHERE `catid` = '$row[id]' ORDER BY `time` DESC LIMIT 3");
    while($post=mysql_fetch_assoc($posts)){  
        
    echo '<div class="small"><a class="url" href="http://'.$set['home'].'/posts/index.php?id='.$post['id'].'">'.$post['name'].'</a></div>';
    
    }
    
    };
    
    echo '<div class="title">Последние комментарии</div>';
        $comments=mysql_query("SELECT * FROM `comments` WHERE `time` > '".(time()-3600*24)."' ORDER BY `time` DESC LIMIT 5");
    if(mysql_num_rows($comments)){
    while($comm=mysql_fetch_assoc($comments)){  
        
        $namecat1=mysql_query("SELECT * FROM `posts` WHERE `id` = '$comm[pid]'");
        $ncat=mysql_fetch_assoc($namecat1);
    echo '<div class="small"><a class="url" href="http://'.$set['home'].'/posts/index.php?id='.$comm['pid'].'">'.$ncat['name'].'</a></div>';
    
    }
    }else{
        echo '<div class="small">Уже давно ничего не комментировалось...</div>';
    }
    
      $online_users = mysql_result(mysql_query("SELECT count(*) FROM `users` WHERE `online` > '".(time()-300)."'"), 0);
      echo '<div class="title">Online</div>';
  echo '<div class="small"><a class="url" href="http://'.$set['home'].'/other.php?a=online">Online: '.$online_users.'</a></div>';

/**
 * @author FROSTY (valik619)
 * @site nadmad.ru
 * @mail valik619@inbox.ru
 */

?>